{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "from matplotlib import pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "x=np.arange(-4,4,1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "8"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y = np.array((x < 2) & (x > -2) ,dtype='int')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.PathCollection at 0x1174f5b38>"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYwAAAD8CAYAAABkbJM/AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAE3ZJREFUeJzt3X+s3fV93/HnazYwmjWEHyYFG2Y03Gg0zWh75GSqNmUhgFNVMW3p4ipqXY3KaxWUTVuzwVADc9YJgrZIFaiTE1ho1BQQTcpNuswxEFRVSoivW8LPelzRpL7AgjMTlnQ0idl7f5zvzQ6Xc+/52Oden3vI8yEdnfP9nM/3+31hrs/rfs/3nK9TVUiSNMrfmnQASdJ0sDAkSU0sDElSEwtDktTEwpAkNbEwJElNLAxJUpMVKYwk25IcTDKX5Johz5+S5K7u+YeSbO7Gz0zyhSTfTnLLonUe7Lb5cHc7eyWySpKOz/pxN5BkHXArcCkwD+xPMlNVTwxMuwp4oaouTLIDuAl4D/A3wG8Bb+5ui723qmbHzShJGt/YhQFs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MOMkySdcCtwLuAi4BfSnLRZFMt6eN0lwOaAkeBf11Vfx94G/C+NfznCvAd4B1V9Q+Ai4FtSd62WjuzMF7tI8C/YfS30Seuqv73wOLrWMOZq+rzVXW0W/wS/S9wrllV9WRVHZx0jmVsBeaq6umq+i5wJ/1ru605VfUnwJFJ52hRVc9V1Z91j79F/ztgLZcymojqW7ja90ndbdVeByyMAUneDTxTVV+ZdJZWC5eIB97L2j7CGPTPgM9NOsSUO95rtKlRks3ATwAPTTbJ8pKsS/Iw/Stt7KuqVcs77je9p86Ia2P9O/rfRF8zlstbVfdW1XXAdUmuBa6mfyn5iRiVtZtzHf3D/t8/kdmGacm7hh3PNdrUKMnfAf4Q+JeLjuTXnKp6Gbi4Oy/46SRvrqpVOV/0A1cYS10bK8mPAxcAX0kC/bdM/izJ1qr6nycw4issdy2vRT4J/DETLIxRWbt/POtngUtqDXye+xj+bNeieWDwKs6bgGcnlOU1JclJ9Mvi96vqU5PO06qqvpnkQfrni1alMHxLqlNVj1bV2VW1uao20/8L+ZOTLItRkmwZWHw38BeTyjJKkm3AvwXeXVX/Z9J5XgP2A1uSXJDkZGAH/Wu7aQzp/7Z4G/BkVf3nSecZJcmGhU8cJjkVeCer+DpgYUy3G5M8luQR+m+lreWPAN4C/DCwr/sY8H+ZdKDlJPm57jpn/xD44yR7J51pUPcBgqvpX9zzSeDuqnp8sqmGS/IHwBeBN3XXjLtq0pmW8dPALwPvGPgnon9m0qGWcQ7whe41YD/9cxifXa2d+U1vSVITjzAkSU0sDElSEwtDktTEwpAkNbEwJElNLAxJUhMLQ5LUxMKQJDX5fyWHk8daNqdXAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x10c3de320>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(x[y==0],np.zeros(len(x[y==0])))\n",
    "plt.scatter(x[y==1],np.zeros(len(x[y==1])))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [],
   "source": [
    "l1,l2 = 1,2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [],
   "source": [
    "def gs(lamda,x,l):\n",
    "    return np.exp(-lamda * (x-l)**2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([-4, -3, -2, -1,  0,  1,  2,  3])"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X=np.empty(shape=(len(x),2))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [],
   "source": [
    "i = 0\n",
    "for data in x:\n",
    "    X[i,0] = gs(0.1,data,l1)\n",
    "    X[i,1] = gs(0.1,data,l2)\n",
    "    i += 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.PathCollection at 0x117a700b8>"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD8CAYAAACMwORRAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAEIVJREFUeJzt3W2InWedx/HvzzRdZ7Emy2YEmwfTZdNgqIXI0O0irJXq9gFsi7jZdimuUgwItbC6gRaXWuILWcNSKHZXu2wRBa1xKTGVSl50K4pY6ZRgaiOBbNVmEqFRm7zpaNPuf1+ckzoZJ5l7knPmdK75fmA4577ui3P+XEx+c+e6H65UFZKktrxp1AVIkgbPcJekBhnuktQgw12SGmS4S1KDDHdJapDhLkkNMtwlqUGGuyQ16KJRffGaNWtq48a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dlJKlBhrskNchwl6QGGe6S1CDDXZIaZLhLUoMMd0lqkOEuSQ36f9bgvXxDoyieAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x117b357f0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(X[y==0,0],X[y==0,1])\n",
    "plt.scatter(X[y==1,0],X[y==1,1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.svm import SVC\n",
    "from sklearn.pipeline import Pipeline\n",
    "from sklearn.preprocessing import StandardScaler\n",
    "from sklearn import datasets\n",
    "from sklearn.model_selection import train_test_split"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [],
   "source": [
    "def PipeSVC(gam,C):\n",
    "    return Pipeline([\n",
    "        ('std_scalar',StandardScaler()),\n",
    "        ('svc',SVC(gamma=gam,C=C))\n",
    "    ])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [],
   "source": [
    "iris=datasets.load_iris()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [],
   "source": [
    "X=iris.data\n",
    "y=iris.target"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {},
   "outputs": [],
   "source": [
    "X_train,X_test,y_train,y_test=train_test_split(X,y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {},
   "outputs": [],
   "source": [
    "svc=PipeSVC(0.0001,0.1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Pipeline(memory=None,\n",
       "     steps=[('std_scalar', StandardScaler(copy=True, with_mean=True, with_std=True)), ('svc', SVC(C=0.1, cache_size=200, class_weight=None, coef0=0.0,\n",
       "  decision_function_shape='ovr', degree=3, gamma=0.0001, kernel='rbf',\n",
       "  max_iter=-1, probability=False, random_state=None, shrinking=True,\n",
       "  tol=0.001, verbose=False))])"
      ]
     },
     "execution_count": 72,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "svc.fit(X_train,y_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.18421052631578946"
      ]
     },
     "execution_count": 73,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "svc.score(X_test,y_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
